%option noyywrap nodefault yylineno case-insensitive
%{
#include<stdio.h>
#include<string.h>
#include"CQLParser_3.tab.h"
void yyerror(char*s, ...);
%}

%%
CREATE { return CREATE; }
MATCH  { return MATCH; }
DELETE { return DELETE; }
REMOVE { return REMOVE; }
RETURN { return RETURN; }
WHERE  { return WHERE; } 
AND    { yylval.subtok=10; return AND; }
OR     { yylval.subtok=11; return OR; }
NOT    { yylval.subtok=12; return NOT; } 
XOR    { yylval.subtok=13; return XOR; }

-?[0-9]+ { yylval.intval=atoi(yytext); return INTNUM; }

-?[0-9]+"."[0-9]* |
-?"."[0-9]+ { yylval.floatval=atoi(yytext); return FLOATNUM; }
  
TRUE { yylval.intval=1; return BOOL; }
FALSE { yylval.intval=0; return BOOL; }

'(\\.|''|[^'\n])*' |
\"(\\.|\"\"|[^"\n])*\" { yylval.strval=strdup(yytext); return STRING; }

"(" { return yytext[0]; }
")" { return yytext[0]; }
"{" { return yytext[0]; }
"}" { return yytext[0]; }
"[" { return yytext[0]; }
"]" { return yytext[0]; }
":" { return yytext[0]; }
"." { return yytext[0]; }
"," { return yytext[0]; }


"="  { yylval.subtok=4; return COMPARISON; }
">=" { yylval.subtok=6; return COMPARISON; }
">"  { yylval.subtok=2; return COMPARISON; }
"<=" { yylval.subtok=5; return COMPARISON; }
"<"  { yylval.subtok=1; return COMPARISON; }
"<>" { yylval.subtok=3; return COMPARISON; }

"->" { yylval.subtok=1; return POINT; }
"-"  { yylval.subtok=2; return CONN; }

[a-zA-Z_]+[a-zA-Z_0-9]* { yylval.strval=strdup(yytext); return ID; }
\n { return EOL; }
[ \t] 
.   { yyerror("invalid char: %c",*yytext); }
%%

